<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <p>fjdskjalf</p>
        <p><h2>fhweioshf</h2></p>
        <p>jfdlskajfkl</p>
        <p><h1>473219874392</h1></p>
        <p>fdsl;ajkf;sd</p>
    </div>
    <button>删除所有p元素</button>
    <script>
        const btn = document.querySelector('button');
        const div = document.querySelector('div');
        btn.addEventListener('click',()=>{
            const ps = div.children;
            for(let i = ps.length - 1;i >= 0;--i){
                div.removeChild(ps[i]);
            }
            // 禁用按钮
            btn.disabled = true;
        });
    </script>
</body>
</html>